<template>
    <view class="log">
        <view class="loglist">
            <view v-for="(fait,indx) in logListArray" :key='indx'>
                <view class="outlogs">
                    <view class="fathvie">
						<view class="loimgc2">
							<view>
								<image class="exchangeImgSmall" v-if="fait.exchangeType=='0'" src="../../static/img/ind0.png"></image>
								<image class="exchangeImgSmall" v-if="fait.exchangeType=='1'" src="../../static/img/ind2.png"></image>
								<image class="exchangeImgSmall" v-if="fait.exchangeType=='2'" src="../../static/img/ind1.png"></image>
							</view>
							<view>
								<image v-if="fait.logType==5" class="noteImgSmall" src="../../static/img/mai.png"></image>
								<image v-else-if="fait.logType==6" class="noteImgSmall" src="../../static/img/sell.png"></image>
								<image v-else class="noteImgSmall" src="../../static/img/tyl.png"></image>
							</view>
						</view>
                        <view class="loimgc">
                            <view class="sdf">
                                {{fait.note}}
                            </view>
                            <view class="timeds">{{fait.modifyTime}}</view>
                        </view>
                    </view>
                </view>
            </view>
        </view>
		<backTop :src="backTop.src"  :scrollTop="backTop.scrollTop"></backTop>
        <view v-show="isLoadMore">
            <uni-load-more :status="loadStatus"></uni-load-more>
        </view>
    </view>
</template>

<script>
    let uinfo;
    import request from "../../untils/request.js";
    import uniLoadMore from '../../components/uni-load-more.vue';
	import backTop from '../../components/back-top/back-top.vue';
    export default {
        components: {
            uniLoadMore,backTop
        },
		onPageScroll(e) {
			this.backTop.scrollTop = e.scrollTop;
		},
        data() {
            return {
				scrollTop: 0,
				backTop: {
					src: '../../static/top.png',
					scrollTop: 0
				},
                logListArray: [],
                loadStatus: 'loading', //加载样式：more-加载前样式，loading-加载中样式，nomore-没有数据样式
                isLoadMore: false, //是否加载中
                page: 1,
                limit: 10
            }
        },
        onLoad() {
            uinfo = uni.getStorageSync('userInfo');
            this.logListFn();
        },
        onShow() {
            let _this=this;
        },
        onPullDownRefresh() {
			this.logListArray = [];
			this.page = 1;
            this.logListFn();
        },
        onReachBottom() { //上拉触底函数
            if (!this.isLoadMore) { //此处判断，上锁，防止重复请求
                this.isLoadMore = true;
                this.page++;
				this.logListFn();
            }
        },
        methods: {
            logListFn() {
                request.postAssets('/assets/walletTransLog/queryWalletTransLog', {
                    userId: uinfo.userId,
                    sortAttribute: "6",
                    sortType: "descend",
					pageNumber: this.page,
					pageSize: this.limit
                }).then(res => {
                    if (res.code == '200') {
                        uni.stopPullDownRefresh();
                        if (res.data.items.length > 0) {
							if(this.page == 1){
								this.logListArray = res.data.items;
							}else{
							    this.logListArray = this.logListArray.concat(res.data.items);
							}
                            //如果最后一页小于每页限制数
                            if (res.data.items.length < this.limit) {
                                this.isLoadMore = true;
                                this.loadStatus = 'nomore';
                            } else {
                                this.isLoadMore = false;
                            }
                        } else {
                            this.isLoadMore = true;
                            this.loadStatus = 'nomore';
                        }
                    } else {
                        uni.stopPullDownRefresh();
                        uni.showToast({
                            icon: "none",
                            title: res.message,
                        });
                    }
                })
            }
        }
    }
</script>

<style>
    .log {
        background: #F5F5F5;
    }

    .loglist {
        width: 710rpx;
        margin: 0 auto;
        padding: 0 0 40rpx 0;
    }

    .loglist .outlogs {
        border-radius: 10px;
        background: #FFFFFF;
    }

    .loglist .outlogs .fathvie {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 20px 0px 19px;
        border-bottom: 1px solid #F1F2F6;
        margin: 0 10px;
    }

    .loglist .outlogs .loimgc {
        width: 580rpx;
    }

    .loglist .outlogs .loimgc2 {
        width: 60rpx;
    }

    .loglist .loimgc .sdf {
        font-size: 16px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #333333;
        margin: 0 0 10px 0;
    }

    .loglist .loimgc .sdf text {
        font-size: 14px;
        color: #ADB0BB;

    }

    .loglist .loimgc .timeds {
        font-size: 14px;
        font-family: Aileron;
        font-weight: 400;
        color: #ADB0BB;
    }
	
	.exchangeImgSmall {
		width: 40px;
		height: 40px;
	}
	
	.noteImgSmall {
		width: 24px;
		height: 24px;
		margin-left: 8px;
	}
	
</style>
